package com.nhjf.service.impl.finetTalk;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.nhjf.command.comment.CreateFinetTalkCommentCommand;
import com.nhjf.dao.finetTalk.FinetTalkCommentDao;
import com.nhjf.dao.finetTalk.FinetTalkDao;
import com.nhjf.model.finetTalk.FinetTalkComment;
import com.nhjf.model.system.User;
import com.nhjf.model.teachers.CoursesComment;
import com.nhjf.pojo.dto.result.ServiceResultDto;
import com.nhjf.pojo.qo.finetTalk.FinetTalkCommentQo;
import com.nhjf.service.finetTalk.FinetTalkCommentService;
import com.nhjf.service.finetTalk.FinetTalkService;
import com.nhjf.service.impl.BaseServiceImpl;

@Transactional
@Service("finetTalkCommentService")
public class FinetTalkCommentServiceImpl extends BaseServiceImpl<FinetTalkComment, FinetTalkCommentQo, FinetTalkCommentDao> implements FinetTalkCommentService{

	@Autowired
	private FinetTalkCommentDao dao;
	
	@Override
	protected FinetTalkCommentDao getDao() {
		// TODO Auto-generated method stub
		return dao;
	}

	@Override
	public ServiceResultDto createFinetTalkComment(CreateFinetTalkCommentCommand createFinetTalkCommentCommand) {
		// TODO Auto-generated method stub
		ServiceResultDto resultDto = new ServiceResultDto();
		FinetTalkComment finetTalkComment=new FinetTalkComment();
		if(StringUtils.isEmpty(createFinetTalkCommentCommand.getComment())) {
			resultDto.setSuccess(false);
			resultDto.setResultMessage("评论内容为空");
		}
		finetTalkComment.setComment(createFinetTalkCommentCommand.getComment());
		finetTalkComment.setCommentTime(new Date());
		finetTalkComment.setCommentType(createFinetTalkCommentCommand.getCommentType());
		finetTalkComment.setCommentUserType(createFinetTalkCommentCommand.getCommentUserType());
		finetTalkComment.setFinetTalkId(createFinetTalkCommentCommand.getFinetTalkId());
		User user=new User();
		user.setId(createFinetTalkCommentCommand.getUserId());
		finetTalkComment.setUser(user);
		dao.save(finetTalkComment);
		resultDto.setSuccess(true);
		resultDto.setResultMessage("评论成功");
		return resultDto;
	}

}
